<div class='_line'></div>
<div >
    <b><a href="<?php echo shop_buildUrl('/user/action/');?>" style='font-size:1.5rem;color:black;'>活动 </a></b>&nbsp;&nbsp;&nbsp;&nbsp;
    <b><a href="<?php echo shop_buildUrl('/user/coupon/check');?>" style='font-size:1.5rem;color:black;' >优惠劵 </a></b>
</div>
<div class='_line'></div>
<div class='_line'></div>
<div class='_cut2'></div>
<div id='content'>    
        <div id="appends">
        <?php foreach($coupons as $k=>$v){ ?>
        <?php if($k%3==0){?>
        
        <div class='row'>    
            <div class='col-sm-3 col-md-4'>
            <?php } ?>

            <div style='text-align:left;font:normal bold 20px/20px arial,sans-serif;color: #999999'><?php echo $v['name'] ?></div>
            <div class="thumbnail"  >
                <div  style="height:12rem;overflow: hidden">           	
                    <a href="/user/coupon/detail?store_id=<?php echo $v['store_id'] ?>&coupon_id=<?php echo $v['id'] ?>&barber_id=<?php echo $barber_id ?>"><img src="<?php echo $v['style']?>" width='100%'></a>
                </div>
            </div>
<!--             <div style='text-align:center;margin-top:-1.5rem;font-size:1.5rem;'>
             <span ><?php echo date('Y-m-d',$v['end_time']); ?>前使用 </span>
            </div> -->
            <div class='_line'></div>
        <?php if(($k+1)%3==0 || $coupons[$k+1]['id']<1){?>
        </div>

        <?php }  ?> 
        <?php }  ?>
        </div>
        </div>
         

<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script> 
<script type='text/javascript'>
    var number = 12;
    function loaddata()
    {
        if(number ==-1){
            return;
        }
        totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());

        if ($(document).height() <= totalheight)
        {
            var barber_id = "<?php echo $barber_id ?>";
            $.ajax({ url: "/user/coupon/appendCheck?store_id=<?php echo (int)$_GET['store_id'];?>&start="+number,async:true, success: function(msg){
                    if(msg == 'false'){
                        number = -1;
                        return ;
                    }
                    var html = "";
                    msg = eval('(' + msg + ')');
                    $.each(msg,function(i,v){
                        if(i%4==0){
                            html += "<div class='row'>";
                            
                        }
                        html += "<div class='col-sm-3 col-md-4'>";
                        html += '<div style="text-align:center;font:italic bold 20px/20px arial,sans-serif;">';
                        html += v.name==null?'':v.name;
                        html += '</div><div class="thumbnail" ">';
                       
                        html += "<div class='caption'><a href='/user/coupon/detail?store_id=";
                        html += v.store_id==null?'':v.store_id;
                        html += "&coupon_id=";
                        html += v.id==null?'':v.id;
                        html += "&barber_id=";
                        html += barber_id==null?'':barber_id;
                        html += "'>";
                        html +="<img width='100%' src='";
                        html += v.style==null?'':v.style;
                        html += "'></a></div>";
                        html += "</div><div style='margin:-2rem 1rem 2rem 1rem;font-size:1.7rem;'>";
                        html += v.intro==null?'':v.intro;
                        html += "</div></div>";
                        if((i+1)%3==0){
                            html += "</div>";
                        }
                        number += 1;
                    });
                    $('#appends').append(html);
                    $.each(msg,function(i,v){
                        html +="<option value='";
                        html +=v.id==null?'':v.id;
                        html +="'>";
                        html +=v.content==null?'':v.content;
                        html +=v.type_name==null?'':v.type_name;
                        html +="</option>";

                    });
                    $('#type').append(html);
            }});
                //$("#container").append(text);
        }
    }

    $(window).scroll(function () {
        loaddata();
    });

   wx.config({
        debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
        appId: '<?php echo  WEIXIN_PAY_APP_ID;?>', // 必填，公众号的唯一标识
        timestamp: '<?php echo $data["timestamp"];?>', // 必填，生成签名的时间戳
        nonceStr: '<?php echo $data["noncestr"];?>', // 必填，生成签名的随机串
        signature: '<?php echo $data["sign"];?>',// 必填，签名，见附录1
        jsApiList: ['onMenuShareTimeline','onMenuShareAppMessage'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
    });
    wx.ready(function () {
    wx.onMenuShareTimeline({
        title: '<?php echo $coupons[0]["name"] ;?>', // 分享标题
        link: '<?php echo $data["url"];?>', // 分享链接
        imgUrl: '<?php echo "http://".MAIN_DOMAIN.$logo;?>', // 分享图标
        success: function () { 
            

        },
        cancel: function () { 
            // 用户取消分享后执行的回调函数

        },
        trigger: function(){
                alert("请点击您要分享的优惠劵,进入详情页再分享。");
                WeixinJsBridge.invoke('disabledShare',{},function(e){
                    //禁止用户分享错误的页面
                })
            }
    });
    wx.onMenuShareAppMessage({
        title: '<?php echo $coupons[0]["name"];?>', // 分享标题
        desc: '<?php echo $coupons[0]["intro"];?>', // 分享描述
        link: '<?php echo $data["url"];?>', // 分享链接
        imgUrl: '<?php echo "http://".MAIN_DOMAIN.$logo;?>', // 分享图标
        type: '', // 分享类型,music、video或link，不填默认为link
        dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
        success: function () { 
            // 用户确认分享后执行的回调函数

        },
        cancel: function () { 
            // 用户取消分享后执行的回调函数

        },
        trigger: function(){
                alert("请点击您要分享的优惠劵,进入详情页再分享。");
                WeixinJsBridge.invoke('disabledShare',{},function(e){
                    //禁止用户分享错误的页面
                })
            }
    });
    }); 
</script>